package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlMember;
import com.ruoyi.hotel.service.IHlMemberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员权限Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hlmember")
public class HlMemberController extends BaseController
{
    @Autowired
    private IHlMemberService hlMemberService;

    /**
     * 查询会员权限列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlMember hlMember)
    {
        startPage();
        List<HlMember> list = hlMemberService.selectHlMemberList(hlMember);
        return getDataTable(list);
    }

    /**
     * 导出会员权限列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:export')")
    @Log(title = "会员权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlMember hlMember)
    {
        List<HlMember> list = hlMemberService.selectHlMemberList(hlMember);
        ExcelUtil<HlMember> util = new ExcelUtil<HlMember>(HlMember.class);
        util.exportExcel(response, list, "会员权限数据");
    }

    /**
     * 获取会员权限详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(hlMemberService.selectHlMemberById(id));
    }

    /**
     * 新增会员权限
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:add')")
    @Log(title = "会员权限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlMember hlMember)
    {
        return toAjax(hlMemberService.insertHlMember(hlMember));
    }

    /**
     * 修改会员权限
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:edit')")
    @Log(title = "会员权限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlMember hlMember)
    {
        return toAjax(hlMemberService.updateHlMember(hlMember));
    }

    /**
     * 删除会员权限
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlmember:remove')")
    @Log(title = "会员权限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hlMemberService.deleteHlMemberByIds(ids));
    }
}
